//
//  XS_DownloadStartHeaderView.swift
//  XueDao
//
//  Created by Mac on 2020/12/29.
//

import UIKit

protocol XS_DownloadStartHeaderViewDelegate {
    func headerView(headerView : XS_DownloadStartHeaderView, didClickFoldBtn: QMUIButton)
}

class XS_DownloadStartHeaderView: UIView {
    
    @IBOutlet weak var numberLabel: UILabel!
    @IBOutlet weak var titleLabel: UILabel!
    @IBOutlet weak var numberBtn: QMUIButton!
    
    var delegate : XS_DownloadStartHeaderViewDelegate?
    /*
    // Only override draw() if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    override func draw(_ rect: CGRect) {
        // Drawing code
    }
    */
    @IBOutlet weak var foldBtn: QMUIButton!
    
    var section : Int = 0
    
    var _model : XS_KCqueryHoursM!
    public var model : XS_KCqueryHoursM!{
        set{
            _model = newValue
            //设置数据
            numberLabel.text = "第"+String(section + 1)+"章"
            titleLabel.text = newValue.chapterName
            foldBtn.isSelected = model.selected
        }
        get{
            return _model
        }
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        foldBtn.imagePosition = .right
        foldBtn.spacingBetweenImageAndTitle = 8
    }
    
    @IBAction func rightBtnAction(_ sender: QMUIButton) {
        if delegate != nil {
            delegate?.headerView(headerView: self, didClickFoldBtn: sender)
        }
    }
}
